#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

const string lst1[20] = {
    "one", "two", "three", "four", "five",
    "six", "seven", "eight", "nine", "ten",
    "eleven", "twelve", "thirteen", "fourteen", "fifteen",
    "sixteen", "seventeen", "eighteen", "nineteen", "twenty"};
const string lst2[3] = {"first", "second", "third"};

int parse(const string &str)
{
    if (str == "a" || str == "another")
        return 1;
    if (str == "both")
        return 2;
    for (int i = 0; i < 20; ++i)
    {
        if (str == lst1[i])
        {
            return i + 1;
        }
    }
    for (int i = 0; i < 3; ++i)
    {
        if (str == lst2[i])
        {
            return i + 1;
        }
    }
    return 0;
}

int main()
{
    int data[6];
    for (int i = 0; i < 6; ++i)
    {
        string buf;
        cin >> buf;
        data[i] = parse(buf);
        data[i] *= data[i];
        data[i] %= 100;
    }
    sort(data, data + 6);
    long long outdata = 0;
    for (int i : data)
    {
        outdata *= 100;
        outdata += i;
    }
    printf("%lld", outdata);
    return 0;
}